<template>
  <span>
    <div class="mui-numbox" data-numbox-min="1" >
      <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
      <input id="test" class="mui-input-numbox" type="number" :value="initcount" @change="countChanged" ref='numbox' readonly>
      <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
  </span>
</template>


<script>
import mui from '../../lib/js/mui.min.js'
export default {
    mounted(){
        mui('.mui-numbox').numbox()
    },
    methods:{
      //每当文本框数据修改时候 最新数据传递给父组件
      countChanged(){
        console.log(this.$refs.numbox.value);
        this.$store.commit('updateGoodsInfo',{
          id:this.goodsid,
          count:this.$refs.numbox.value
        })
       
      }
    },
    props:['initcount',"goodsid"]
};
</script>

<style lang='scss' scoped>
.mui-numbox{
    height: 25px;
}
</style>
